<div id="div_update_responsavel">
<br />
    <table width="100%">
        <tr>
            <td></td>
            <td align="right">
                <a href="#">
                    <img id="protegeDadosResponsavel" alt="1" src="<?php echo base_url() . 'assets/images/lock.gif' ?>" border="0" title="Bloqueado"  width="30" height="30"/>
                </a>
            </td>
        </tr>
    </table>
<form id="updateResponsavel">
    <p><b>Dados do Respons&aacute;vel</b></p>
    <fieldset style="width:auto;">
    <legend style="size:auto; font-weight:bold; color:#333333">Dados B&aacute;sicos</legend>
    <br />
  <table  width="100%">
        <tr>
            <td align="right">Nome:</td>
            <td align="left"><input type="text" size="80" id="aNomeResponsavel" value="<?= $respNome; ?>" disabled /></td>
            <td align="right">CPF:</td>
            <td align="left"><input type="text"  disabled size="15" id="aCpfResponsavel" onkeypress="mascara(this,cpf)" maxlength="14" value="<?= $respCpf; ?>"/></td>
        </tr>
        <tr>
            <td align="right">Identidade:</td>
            <td align="left"><input type="text"  disabled size="20" id="aIdtResponsavel" value="<?= $respIdt ?>" />
                &Oacute;rgao Expedidor:<input  disabled type="text" size="20" id="aIdtExpResponsavel" value="<?= $respExpIdt ?>"/>
            </td>
            <td align="right">Parentesco:</td>
            <td align="left">
                <select id="aParentesco"  disabled >
                  <option value="<?= @$respParentescoCod ?>"><?= $respParentesco; ?></option>  
                  <option value='1'>Pai</option>
                  <option value='2'>M&atilde;e</option>
              </select>
            </td>            
        </tr>
        <tr>
            <td align="right">E-Mail:</td>
            <td align="left"><input  disabled type="text" size="40" id="aEmailResp" value="<?= $respEMail; ?>"/></td>

            <td align="right">Profiss&atilde;o:</td>
            <td align="left">
                <select id="aProfissao"  disabled >
                  <option value='<?= @$respProfissaoCod ?>'><?= @$respProfissao; ?></option>
                  <option value='1'>Arquiteto</option>
                  <option value='2'>Engenheiro Florestal</option>
                  <option value='3'>Funcion&aacute;rio P&uacute;blico</option>
              </select>
        </tr>
        <tr><td>&nbsp;</td></tr>
        <tr>
            <td colspan="4" align="left">Respons&aacute;vel Financeiro:
                <input type="checkbox" id="aResponsavelDireto" value="1" <?= ($respDireto == 1) ? 'checked' : '' ?>  disabled />
            </td>
        </tr>
    </table>
    <br />
    </fieldset>
    <br /><br />
    <fieldset style="width:auto;">
    <legend style="size:auto; font-weight:bold; color:#333333">Endere&ccedil;o</legend>
    <br />
    <table>       
        <tr>
            <td width="71" align="right">CEP:</td>
            <td width="181" align="left"><input type="text" size="9" id="aCepResp" value="<?= $cep; ?>" disabled /></td>
            <td width="133" align="right">Endere&ccedil;o:</td>
            <td colspan="2" align="left"><input type="text" size="80" id="aLogradouroResp" value="<?= $logradouro; ?>" disabled /></td>
        </tr>
        <tr><td colspan="5">&nbsp;</td></tr>
        <tr>            
            <td align="right">Bairro:</td>
            <td align="left"><input type="text" size="20" id="aBairroResp" value="<?= $bairro; ?>"  disabled /></td>
            <td align="right">Complemento:</td>
            <td colspan="2" align="left"><input type="text" size="50" id="aComplementoResp" value="<?= $complemento; ?>"  disabled /></td>
        </tr>
        <tr><td colspan="5">&nbsp;</td></tr>
        <tr>
            <td align="right">Cidade/UF:</td>
            <td align="left" colspan="3"><input type="text" size="45" id="aCidadeResp" value="<?= $cidade ?>"  disabled />/<input type="text" size="3" maxlength="2" id="aUfResp" value="<?= $uf ?>"  disabled /></td>
            <td width="442">Tipo do Endere&ccedil;o:
              <select name="aTipoEnderecoResp" disabled id="aTipoEnderecoResp" >
                <option value='<?= @$tipoEnderecoCod; ?>'>
                  <?= $tipoEndereco; ?>
                </option>
                <option value='1'>Residencial</option>
                <option value='2'>Comercial</option>
                <option value='3'>Outro</option>
              </select></td>
        </tr>
    </table>
    <br />
    </fieldset>
    <br /><br />
    <fieldset style="width:auto;">
    <legend style="size:auto; font-weight:bold; color:#333333">Telefones</legend>
    <br />
  <table>
        
        <tr>
            <td align="right" width="16%">Residencial:</td>
            <td align="left" width="16%"><input  disabled type="text" size="13" maxlength="13" id="aTelResidencialResp" onkeypress="mascara(this,telefone)" value="<?= $foneFixo ?>" /></td>
            <td align="right" width="16%">Celular:</td>
            <td align="left" width="16%"><input  disabled type="text" size="13" maxlength="13" id="aCelularResp" onkeypress="mascara(this,telefone)" value="<?= $foneCelular ?>"/></td>
            <td align="right" width="16%">Trabalho:</td>
            <td align="left"><input type="text"  disabled size="13" id="aTelefoneTrabalhoResp" maxlength="13" onkeypress="mascara(this,telefone)" value="<?= $foneTrabalho; ?>"/></td>
        </tr>
    </table>
    <br />
    </fieldset>
<br /><br />
     <fieldset style="width:auto;">
    <legend style="size:auto; font-weight:bold; color:#333333">Dados Banc&aacute;rios</legend>
    <br />
  <table>
            
        <tr>
            <td align="right" width="16%">Banco:</td>
            <td align="left" width="16%">
                <select id="aBancoResp" disabled >
                  <option value='<?= @$bancoCod ?>'><?= @$banco ?></option>
                  <option value='001'>Banco do Brasil</option>
                  <option value='002'>Itau</option>
                  <option value='003'>Bradesco</option>
                  <option value='004'>Santander</option>
                  <option value='005'>BRB</option>
              </select></td>
            <td align="right" width="16%">Conta Corrente:</td>
            <td align="left" width="16%"><input type="text" size="13" id="aContaResp" value="<?= @$conta; ?>"  disabled /></td>
            <td align="right" width="16%">Ag&ecirc;ncia:</td>
            <td align="left"><input type="text" size="13" id="aAgenciaResp" value="<?= @$agencia ?>"  disabled /></td>
            <td align="right" width="16%">D&eacute;bito Autom&aacute;tico:</td>
            <td align="left">
                <select id="aDebitoAutomatico"  disabled >
                  <option value=''><?= @$debAutomatico ?></option>
                  <option value='1'>Sim</option>
                  <option value='0'>N&atilde;o</option>
              </select>            </td>
        </tr>
        <tr>
          <td colspan="8" align="right">&nbsp;</td>
        </tr>
        <tr>
            <td align="right" width="16%">
                <input type="checkbox" id="aCheque" value="1" <?= ($respCheque == 1) ? 'checked' : '' ?> disabled /></td>
            <td align="left" width="16%">Cheque devolvido</td>
            <td align="right" width="16%">
                <input type="checkbox" id="aTxMaterial" value="1" <?= ($respTxMaterial == 1) ? 'checked' : '' ?> disabled /></td>
            <td colspan="3" align="left">Taxa de Material em aberto</td>
            <td align="right" width="16%"></td>
            <td align="left"></td>
        </tr>
    </table>
    <br />
    </fieldset>
<br />
    <input type="hidden" id="alunoId" value="<?= @$alunoId; ?>"   />
    <input type="hidden" id="respCod" value="<?= @$respCod; ?>"   />
    <div align="center"><input type="button" onclick="atualizarDadosResponsavel()" id="btnAtualizarResponsavel" value="Atualizar"></div>
</form>
</div>
<script>
$(document).ready(
        function(){
                $("#updateResponsavel input").attr("disabled", true);
                $("#updateResponsavel select").attr("disabled", true);
                $("#updateResponsavel textarea").attr("disabled", true);
                // Desabilita os submits
                $("#updateResponsavel input[type='button'],#updateResponsavel input[type='image']").attr("disabled", true);
                
                $('#protegeDadosResponsavel').attr({
                            title:"Bloqueado",
                            src:"<?php echo base_url() . 'assets/images/lock.gif' ?>"
                    });

                    $("#protegeDadosResponsavel").removeClass("desbloqueado").addClass("bloqueado");
                

                $('#protegeDadosResponsavel').click(function(){

                    $("#updateResponsavel input").attr("disabled", false);
                    $("#updateResponsavel select").attr("disabled", false);
                    $("#updateResponsavel textarea").attr("disabled", false);
                    // Desabilita os submits
                    $("#updateResponsavel input[type='button'],#updateResponsavel input[type='image']").attr("disabled", false);

                    $('#protegeDadosResponsavel').attr({
                            title:"Desbloqueado",
                            src:"<?php echo base_url() . 'assets/images/unlock.gif' ?>"
                    });

                    $("#protegeDadosResponsavel").removeClass("bloqueado").addClass("desbloqueado");

                });
            

           $('#aCepResp').change(function(){

                jQuery.ajax( {
                    type: "POST",
                    url: '?c=c_responsavel&m=buscaEnderecoResponsavel',
                    cache: false,
                    data: {cep:jQuery('input[id="aCepResp"]').val()},
					
                    beforeSend: function (){
                            jQuery('#btnAtualizarResponsavel').attr("disabled",true);
                            jQuery('#div_body').addClass("div_carregando");
                            jQuery('#aLogradouroResp').attr('readonly', true);
                            jQuery('#aBairroResp').attr('readonly', true);
                            jQuery('#aCidadeResp').attr('readonly', true);
                            jQuery('#aUfResp').attr('readonly', true);
                    },
                    complete:  function(){
                           jQuery('#div_body').removeClass("div_carregando");
                           jQuery('#btnAtualizarResponsavel').attr("disabled",false);
                        },
                    success: function(data){
                        
                        var dados = data.split('@');
                       
                        if(dados[0] == 1){
						
                            jQuery('#aLogradouroResp').attr('value', dados[1]);
                            jQuery('#aBairroResp').attr('value', dados[2]);
                            jQuery('#aCidadeResp').attr('value', dados[3]);
                            jQuery('#aUfResp').attr('value', dados[4]);

                        } else if(dados[0] == 2){
						
                            jQuery('#aCidadeResp').attr('value', dados[1]);
                            jQuery('#aUfResp').attr('value', dados[2]);
							
                        } else {
						
                                jQuery('#aLogradouroResp').attr('readonly', false);
                                jQuery('#aBairroResp').attr('readonly', false);
                                jQuery('#aCidadeResp').attr('readonly', false);
                                jQuery('#aUfResp').attr('readonly', false);

                        }
                        
                    }
                });

            });
        });
</script>    
